
let fs = require("fs-extra");
let path = require("path")
let chalk = require("chalk");
let ora = require("ora");
var program = require('commander')
let download = require("download-git-repo");
let readline = require("readline")
let inquirer = require("inquirer")


module.exports.setup  = function   (program) {
  return program
  .command('setup1')
  .description('run remote setup commands')
  .action(function () {
    console.log('setup');
  });
}


module.exports.tear = function (program) {
  return program
  .command('teardown1 <dir> [otherDirs...]')
  .description('run teardown commands')
  .action(function (dir, otherDirs) {
    console.log('dir "%s"', dir);
    if (otherDirs) {
      otherDirs.forEach(function (oDir) {
        console.log('dir "%s"', oDir);
      });
    }
  });
}

// exports = {
//   setup
// }

module.exports.list = function (program) {
  return program
  .command('list')
  .description('问题列表')
  .action(function () {
    inquirer.prompt([{
      type: 'expand', // list  rawlist expand
      message: '请选择一种水果:',
      name: 'fruit',
      choices: [{
          key: "a",
          name: "Apple",
          value: "apple"
        },
        {
          key: "O",
          name: "Orange",
          value: "orange"
        },
        {
          key: "p",
          name: "Pear",
          value: "pear"
        }
      ]
    }]).then((answers) => {
      console.log('结果为:');
      console.log(answers)
    })
  })
}



program
  .command('password')
  .description('密码')
  .action(function () {
    inquirer.prompt([{
      type: 'password',
      message: '请输入密码',
      name: 'pwd'
    }]).then(answers => {
      console.log(answers)
    })
  })




